<template>
  <!-- <div id="app"> -->
  <!-- <img alt="Vue logo" src="./assets/logo.png">
    <HelloWorld msg="Welcome to Your Vue.js App"/> -->

  <div class="lg">
    <span class="loginx">


      <h2>LOGIN</h2>
      <div class="input-item flex">
        <input v-model="username" type="text" required>
        <span>账户</span>
        <i></i>
      </div>
      <div class="input-item flex">
        <input v-model="password" type="password" required @keyup.enter="login()">
        <span>密码</span>
        <i></i>
      </div>


      <button class="btn" type="button" @click="login()">登录</button><br>
      <span class="s1">
        <a target="_blank" @click="ss()">注册</a>
        <a href="http://www.4399.com" target="_blank">注册</a>
        <a href="/"> ss </a>
      </span>
      <span class="s2">
        <a href="/wangjimima" target="_blank">忘记密码?</a></span>

    </span>
  </div>

  <!-- <input type="file" />
    <input type="txt" />
    <input type="button" value="">
    <input type="date" name="" id="">
    <input type="checkbox" name="" id="">
    <input type="radio" name="" id=""> -->

  <!-- </div> -->
</template>

<script>
import { setStore,setUser } from '@/util/store'
import { loginRequest } from '@/api/loginRequest'

export default {
  name: 'App',
  // components: { HelloWorld }/,
  data() {
    return {
      username: '',
      password: '',
      data: [],
    }
  },
  methods: {
    login() {
      let username = this.username;
      let password = this.password;

      console.log(username + ' ___ ' + password);
      loginRequest(username, password).then(res => {
        const data = res.data;
        console.log(data);
        if (res.code == 200) {
          setStore('TOKEN', data.Token);
          setUser(data.User)
          window.location.href = '/';
        }
        // this.$message({
        //     showClose: true,
        //     center: true,
        //     type: 'success',
        //     message: res.msg
        //     });

      })
    },
    ss() {
      console.log("我被点击了");
      setStore('signin', true)
      // window.location.href = '/signin';
      // location.href= '/signin';
      window.open('/signin', "注册")

    }
  }
}
</script>

<style scoped >
.lg {

  display: flex;
  height: 100vh;
  background-image: url(@/static/puren.jpg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}


.loginx {
  display: block;
  background-color: rgb(249, 249, 249, 0.5);
  /* background-image: #9c27b0; */
  width: 30%;
  height: 400px;
  border-radius: 5%;

  margin: auto;
  margin-top: 5%;
  text-align: center;
  padding: 50px 50px;
}

.btn {
  border: none;
  text-align: center;
  padding: 10px;
  width: 100%;
  margin-top: 20px;
  margin-bottom: 10px;
  background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
  color: #fff;
}

.btn:hover {
  background-image: linear-gradient(to right, rgba(166, 193, 238, 0.80), rgba(251, 194, 235, 0.80));
}

.input-item {
  position: relative;
  width: 100%;
  margin-bottom: 30px;
  height: 55px;

}

.s1,
.s2 {

  padding-right: 30px;
  padding-left: 30px;

}

h2 {
  /* color: chocolate; */
  color: rgb(210, 30, 30);
  margin-top: 5%;
}

.input-item input {
  width: 100%;
  background: transparent;
  color: #000;
  padding: 15px 0 5px;
  border: 0;
  height: 40px;
  outline: none;
}

.input-item span {
  position: absolute;
  left: 0;
  padding: 15px 0 5px;
  text-transform: uppercase;
  transition: .5s;
  color: #00e7ff;
  /* color:#9c27b0; */
  font-size: large;
}


.input-item input:valid~span,
.input-item input:focus~span {
  color: #2196f3;

  transform: translateY(-16px);
  font-size: 0.85em;

}

.input-item i {
  position: absolute;
  left: 0;
  bottom: 0;
  width:
    100%;
  height: 2px;
  background: rgb(0, 0, 0);
  overflow: hidden;

}

.input-item i::before {
  content: '';
  position: absolute;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff1b69, #ff0, #2196f3, #9c27b0, #ff1b69);
  animation: animate 2s linear infinite;

}

.input-item input:valid~i::before,
.input-item input:focus~i::before {
  left: 0;

}

@keyframes animate {
  0% {
    background-posiion-x: 0;
  }

  100% {
    background-posiion-x: 300px;
  }
}</style>
